package edu.bit.water.controller;

import edu.bit.water.entity.MetaStandard;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;


import edu.bit.water.service.MetaStandardService;

@Controller
@RequestMapping("/meta_standard")
public class MetaStandardController {

    @Autowired
    private MetaStandardService metaStandardService;

    @ResponseBody
    @RequestMapping(value = "/select", method=RequestMethod.GET)
    public Map<String, Object> queryStandard() {
        Map<String, Object> result = new HashMap<>();
        List<MetaStandard> list = metaStandardService.queryStandard();
        result.put("rows", list);
        return result;
    }

    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> insertMetaStandard(MetaStandard metaStandard) {
        //metaStandard.showContent();
        Map<String, Object> result = metaStandardService.insertMetaStandardService(metaStandard);
        return result;
    }

    /**
     * 删除metaStandard
     * author Page
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> deleteMetaStandard(@RequestBody List<String>metaStandards) {
        return metaStandardService.deleteMetaStandards(metaStandards);
    }

    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> updateMetaStandard(MetaStandard metaStandard) {
        Map<String, Object> result = metaStandardService.updateMetaStandardService(metaStandard);
        return result;
    }
}
